/*******************************************************************************
 * here defined all the data for the project change here change everything
 * 
 * has a base function: createHTML(view, jqueryParent)
 * 
 */

/*
 * |----------------------------| |----------------------------| |label | item *
 * |addition item | |----------------------------|
 * |----------------------------|
 * 
 * div-->table-->label -->item-->item2
 * 
 * some basic attribute: "type":"button",div,checkbox,radio label: style:
 * 
 */

var serverLocation = window.serverLocation = "http://spitfire-project.eu:8182/ld4s";

/**
 * 
 * "http://localhost:8182/ld4s" is right "http://localhost:8182/ld4s/"is wrong
 * http://spitfire-project.eu:8182/ld4s
 */
var TreeCount = 100;// to give the tree id
var map = window.map = new Array();
// google.maps.visualRefresh = true;

// //////////////////
// /////////
// here is the share part

var sharedViewContent = {
	"type" : "div",
	"style" : "Field-content-hide",
	"content" : {
		"contextbutton" : {
			"type" : "checkbox",
			"label" : "Context Search Setting:",
			"style" : "contextbuttonDiv",
			"value" : "enable",
			"click" : function() {
				if ($("#contextbutton").attr("checked") == "checked" || $(this).attr("checked") == "true") {
					$("#context").slideDown();
					$("#contextbutton").parent().parent().find("span").html("disable");
					$("#contextbutton").attr("checked", true);
				} else {
					$("#context").slideUp();

					$("#contextbutton").parent().parent().find("span").html("enable");

					$("#contextbutton").attr("checked", false);

				}

			}
		},
		"context" : {
			"type" : "div",
			"style" : "Field-content-hide",
			"content" : {
				"contextMessage" : {
					"type" : "label",
					"message" : "If you want to link the data sections selected above with external information, in order to better define their context: Which criteria do you want to apply in the search for external information?",
					"style" : "label-message"
				},
				"geography" : {
					"type" : "checkbox",
					"label" : "Geography",
					"style" : "contextbuttonDiv",
					"value" : "add",

				},
				"crossdomain" : {
					"type" : "checkbox",
					"label" : "Cross-domain",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"government" : {
					"type" : "checkbox",
					"label" : "Government",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"media" : {
					"type" : "checkbox",
					"label" : "Media",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"usergenerated" : {
					"type" : "checkbox",
					"label" : "User Generated Content",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"publication" : {
					"type" : "checkbox",
					"label" : "Publication",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"lifescience" : {
					"type" : "checkbox",
					"label" : "Life Science",
					"style" : "contextbuttonDiv",
					"value" : "add"
				},
				"SelectCriteria" : {
					"type" : "label",
					"message" : "Select criteria to consider while linking:",
					"style" : "label-message"
				},
				"LocationsLabel" : {
					"type" : "label",
					"message" : "Locations (select one item and click button to add condition):",
					"style" : "label-message"
				},
				"NEAR" : {
					"label" : "NEAR",
					"type" : "tree",
					"style" : "Tree-div"

				},
				"UNDER" : {
					"label" : "UNDER",
					"type" : "tree",
					"style" : "Tree-div"
				},
				"OVER" : {
					"label" : "OVER",
					"type" : "tree",
					"style" : "Tree-div"
				},
				"IN" : {
					"label" : "IN",
					"type" : "tree",
					"style" : "Tree-div"
				},
				"OF" : {
					"label" : "OF",
					"type" : "tree",
					"style" : "Tree-div"
				},
				"Things" : {
					"label" : "Things",

					"type" : "tree",
					"style" : "Tree-div"
				},
				"start_datetime" : {
					"label" : "start:",
					"type" : "date",
					"level" : "0",
					"defaultValue" : "",
					"isData" : "true"
				},
				"end_datetime" : {
					"label" : "end:",
					"type" : "date",
					"level" : "0",
					"defaultValue" : "",
					"isData" : "true"
				}

			}
		},
		"commonChoiceLabel" : {
			"type" : "checkbox",
			"label" : "optional choice:",
			"style" : "contextbuttonDiv",
			"value" : "enable",
			"click" : function() {

				if ($("#commonChoiceLabel").attr("checked") == "checked" || $(this).attr("checked") == "true") {
					$("#commonChoiceDiv").slideDown(500, function() {
						for ( var key in map) {
							google.maps.event.trigger(map[key], 'resize');
						}

					});

					$("#commonChoiceLabel").parent().parent().find("span").html("disable");
					$("#commonChoiceLabel").attr("checked", true);

				} else {
					$("#commonChoiceDiv").slideUp();

					$("#commonChoiceLabel").parent().parent().find("span").html("enable");

					$("#commonChoiceLabel").attr("checked", false);

				}
			}

		},
		"commonChoiceDiv" : {
			"type" : "div",
			"style" : "Field-content-hide",
			"content" : {

				"base_datetime" : {
					"label" : "base datetime:",
					"type" : "datetime",
					"level" : "0",
					"defaultValue" : "",
					"isData" : "true"
				},
				"SendingURI" : {
					"label" : "send server:",
					"type" : "uri",
					"level" : "0",
					"defaultValue" : window.serverLocation.replace("http://", ""),
					"isData" : "true"
				},
				"archive" : {
					"label" : "archive:",
					"type" : "uri",
					"level" : "0",
					"isData" : "true"
				},
				"description" : {
					"label" : "description",
					"type" : "input",
					"style" : "",
					"level" : "0",
					"defaultValue" : "",
					"isData" : "true"
				}
			}
		},
		"AuthorLabel" : {
			"type" : "checkbox",
			"label" : "Author information:",
			"style" : "contextbuttonDiv",
			"value" : "enable",
			"click" : function() {
				if ($("#AuthorLabel").attr("checked") == "checked" || $(this).attr("checked") == "true") {
					$("#AuthorDiv").slideDown();
					$("#AuthorLabel").parent().parent().find("span").html("disable");
					$("#AuthorLabel").attr("checked", true);
				} else {
					$("#AuthorDiv").slideUp();

					$("#AuthorLabel").parent().parent().find("span").html("enable");

					$("#AuthorLabel").attr("checked", false);

				}
			}
		},
		"AuthorDiv" : {
			"type" : "div",
			"style" : "Field-content-hide",
			"content" : {
				"surname" : {
					"label" : "surname:",
					"type" : "input",
					"defaultValue" : "",
					"isData" : "true"
				},
				"firstname" : {
					"label" : "firstname:",
					"type" : "input",

					"defaultValue" : "",
					"isData" : "true"
				},
				"email" : {
					"label" : "email:",
					"type" : "input",
					"defaultValue" : User.Email,
					"isData" : "true"
				},
				"homepage" : {
					"label" : "homepage:",
					"type" : "uri",
					"isData" : "true"
				},
				"nickname" : {
					"label" : "nickname:",
					"type" : "input",

					"defaultValue" : "",
					"isData" : "true"
				},
				"weblog" : {
					"label" : "weblog:",
					"type" : "uri",
					"isData" : "true"
				}
			}
		},
	/*
	 * "storeDataLabel" : { "type" : "checkbox", "label" : "Store data:",
	 * "style" : "contextbuttonDiv", "value" : "enable", "click" : function() {
	 * if ($("#storeDataLabel").attr("checked") == "checked" ||
	 * $(this).attr("checked") == "true") { $("#storeDiv").slideDown();
	 * $("#storeDataLabel").parent().parent().find("span").html("disable");
	 * $("#storeDataLabel").attr("checked", true); } else {
	 * $("#storeDiv").slideUp();
	 * 
	 * $("#storeDataLabel").parent().parent().find("span").html("enable");
	 * 
	 * $("#AuthorLabel").attr("checked", false); } } },
	 */

	}
};

var storeDiv = {
	"type" : "div",
	"style" : "",
	"content" : {
		"storeType" : {
			"value" : "",
			"style" : "",
			"type" : "radio",
			"label" : "store place:",
			"children" : {
				"storeChoice1" : {
					"label" : "store on spitfire server",
					"value" : "spitfire",
					"checked" : "true",
					"click" : function() {
						$("#uriOutDiv").slideUp();
					}
				},
				"storeChoice2" : {
					"label" : "store on my database",
					"value" : "myDB",
					"checked" : "false",
					"click" : function() {
						$("#uriOutDiv").slideDown();
					},
				}

			}
		},
		"uri" : {
			"label" : "uri:",
			"type" : "uri",
			"style" : "hide",
			"level" : "0",
			"isData" : "true"
		},

		"serializeType" : {
			"type" : "radio",
			"label" : "  Serialize as:",
			"children" : {
				"json" : {
					"label" : "RDF/JSON",
					"value" : "application/rdf+json",
					"checked" : "true"
				},
				"xml" : {
					"label" : "RDF/XML",
					"value" : "application/rdf+xml",
					"checked" : "false"
				},
				"ntriple" : {
					"label" : "N-Triples",
					"value" : "text/n-triples",
					"checked" : "false"
				},
				"turtle" : {
					"label" : "Turtle",
					"value" : "text/*",
					"checked" : "false"
				}
			}
		}
	}
};

var sharedView = {
	"type" : "div",
	"style" : "",
	"content" : {
		"generalButton" : {
			"type" : "checkbox",
			"label" : "Advance Search:",
			"style" : "contextbuttonDiv",
			"value" : "enable",
			"click" : function() {
				if ($("#generalButton").attr("checked") == "checked" || $(this).attr("checked") == "true") {
					$("#sharedViewContent").slideDown();
					$("#generalButton").parent().parent().find("span").html("disable");
					$("#generalButton").attr("checked", true);
				} else {
					$("#sharedViewContent").slideUp();
					$("#generalButton").parent().parent().find("span").html("enable");
					$("#generalButton").attr("checked", false);
				}
			}
		},
		"sharedViewContent" : sharedViewContent
	}

};

// ov json
var ov = {
	"metro" : {
		"title" : "observation value",
		"location" : "AjaxField.html",
		"description" : "give you the observation value from this page",
		"hide" : "false"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/ov/",
			"type" : "post",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : " Sensor Reading:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : "sensor-id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"values" : {
						"label" : "values:",
						"type" : "input",
						"level" : "2",
						"defaultValue" : "",
						"isData" : "true"

					},
					"start_range" : {
						"label" : "start time:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"end_range" : {
						"label" : "end time:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "OV",
						"isData" : "true"
					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data
					var data = GetCommonData();
					// get url info
					var commonData = GetAjaxData();
					if (request("key") != "") {
						var key = request("key");
					} else {
						key = window.key;
					}

					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);
					var PostData = $.extend(data.sendData, commonData);

					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;// use
						// default
					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use
						// special
					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();
				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// device data
var device = {
	"metro" : {
		"title" : "Device, Sensing Device and Sensor",
		"location" : "AjaxField.html",
		"description" : "Control the Device",
		"hide" : "false"
	},
	"page" : {
		"ajax" : {
			"url" : "/device/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"DeviceLabel" : {
				"type" : "label",
				"message" : "Device, Sensing Device, Sensor :",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"OpenNewDialog" : {
						"type" : "button",
						"style" : "open-dialog-button",
						"labelStyle" : "label",
						"label" : "Sensor Temporal property:",
						"value" : "open",
						"click" : function() {
							$("#tps_menu", window.parent.document).trigger("click");

						}
					},
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : "device id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"tsproperties" : {
						"label" : "Sensor Temporal Properties URIs:",
						"type" : "input",
						"level" : "2",
						"labelStyle" : "label-red",
						"isData" : "true"
					},
					"observation_values" : {
						"label" : "Observation Value instances:",
						"type" : "input",
						"level" : "2",
						"labelStyle" : "label",
						"isData" : "true"
					},
					"platform" : {
						"label" : "platform:",
						"type" : "input",
						"isData" : "true"
					},

					"observed_property" : {
						"label" : "Observed Property:",
						"type" : "input",
						"isData" : "true"
					},
					"uom" : {
						"label" : "Unit of Measurement:",
						"type" : "input",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "Device",
						"isData" : "true"
					}

				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"value" : "generate",
				"click" : function() {
					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {

						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use
					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}

					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();
				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// Sensor Temporal Property
var tps = {
	"metro" : {
		"title" : "Sensor Temporal Property",
		"location" : "AjaxField.html",
		"description" : "description of Sensor Temporal Property",
		"hide" : "true"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/tps/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : " Sensor Temporal Property:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : "Sensor property id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"net_links" : {
						"label" : "URIs of opened network links:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "2",
						"defaultValue" : "",
						"isData" : "true"
					},
					"net_role" : {
						"label" : "Network role:",
						"type" : "uri",
						"isData" : "true"

					},
					"foi" : {
						"label" : "Feature of Interest:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"start_range" : {
						"label" : "start range:",
						"type" : "date",
						"isData" : "true"
					},
					"end_range" : {
						"label" : "end range:",
						"type" : "date",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "tps",
						"isData" : "true"
					},
					"location_name" : {
						"label" : "location name:",
						"type" : "input",
						"style" : "",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"location_coords" : {
						"label" : "location coords:",
						"type" : "map",
						"style" : "map-out-div",
						"isData" : "true",
						"click" : function(result) {

							$("#location_name").val(result[0].formatted_address);
						}
					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// Platform, Testbed
var platform = {
	"metro" : {
		"title" : "Platform, Testbed",
		"location" : "AjaxField.html",
		"description" : "description of Platform, Testbed",
		"hide" : "false"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/platform/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "Platform, Testbed:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"OpenNewDialog" : {
						"type" : "button",
						"style" : "open-dialog-button",
						"labelStyle" : "label",
						"label" : "Platform Temporal property:",
						"value" : "open",
						"click" : function() {
							$("#tpp_menu", window.parent.document).click();

						}
					},
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : "platform id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"tpproperties" : {
						"label" : "Platform Temporal Properties URIs:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "2",
						"defaultValue" : "",
						"isData" : "true"
					},

					"feeds" : {
						"label" : "Feeds URI:",
						"type" : "uri",
						"level" : "2",
						"isData" : "true"

					},
					"status" : {
						"label" : "Status URI:",
						"type" : "uri",
						"isData" : "true"

					},
					"foi" : {
						"label" : "Feature of Interest:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "Platform",
						"isData" : "true"

					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// Platform Temporal Property
var tpp = {
	"metro" : {
		"title" : "Platform Temporal Property",
		"location" : "AjaxField.html",
		"description" : "description of Platform Temporal Property",
		"hide" : "true"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/tpp/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "Platform Temporal Property:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : "Platform Temporal Property id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"systems" : {
						"label" : "Attached devices URIs:",
						"type" : "uri",
						"labelStyle" : "label",
						"level" : "2",
						"isData" : "true"
					},
					"algorithms" : {
						"label" : "Algorithms in use:",
						"type" : "uri",
						"level" : "2",
						"isData" : "true"

					},
					"plarform_id" : {
						"label" : "platform id:",
						"type" : "input",
						"level" : "0",
						"isData" : "true"
					},
					"deployment" : {
						"label" : "deployment:",
						"type" : "input",
						"level" : "0",
						"isData" : "true"
					},
					"start_range" : {
						"label" : "start range:",
						"type" : "date",
						"isData" : "true"
					},
					"end_range" : {
						"label" : "end range:",
						"type" : "date",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "tpp",
						"isData" : "true"
					},
					"location_name" : {
						"label" : "location name:",
						"type" : "input",
						"style" : "",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"location_coords" : {
						"label" : "location coords:",
						"type" : "map",
						"style" : "map-out-div",
						"isData" : "true",
						"click" : function(result) {

							$("#location_name").val(result[0].formatted_address);
						}
					},
					"owners" : {
						"label" : "Owners:",
						"type" : "muti-input",
						"level" : "2",
						"children" : {
							"surname" : {
								"label" : "surname:",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							},
							"firstname" : {
								"label" : "firstname",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							}
						},
						"isData" : "true"
					},
					"worn_by" : {
						"label" : "Carriers:",
						"type" : "muti-input",
						"children" : {
							"surname" : {
								"label" : "surname:",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							},
							"firstname" : {
								"label" : "firstname",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							}
						},
						"isData" : "true"
					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}
					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}

					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// data link
var data_link = {
	"metro" : {
		"title" : "data link",
		"location" : "AjaxField.html",
		"description" : "description of data link",
		"hide" : "false"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/link/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "data link:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : " data link id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"to" : {
						"label" : "to:",
						"type" : "uri",
						"labelStyle" : "label",
						"isData" : "true"
					},
					"title" : {
						"label" : "title:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"updated" : {
						"label" : "updated:",
						"type" : "datetime",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"feedbacks" : {
						"label" : "feedbacks:",
						"type" : "uri",
						"level" : "2",

						"isData" : "true"

					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "DataLink",
						"isData" : "true"
					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}
					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}

					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};
// Link Review

var link_review = {
	"metro" : {
		"title" : "Link Review",
		"location" : "AjaxField.html",
		"description" : "description of Link Review",
		"hide" : "true"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/link/feedback/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "Link Review:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					/* "storeDiv" : storeDiv, */
					"resourceId" : {
						"label" : " Link Review id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : guid(),
						"isData" : "true"
					},
					"vote" : {
						"label" : "Vote:",
						"type" : "input",
						"labelStyle" : "label",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"link" : {
						"label" : "DataLink URI:",
						"type" : "uri",
						"level" : "0",

						"isData" : "true"

					},
					"comment" : {
						"label" : "Comment:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"

					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "LinkReview",
						"isData" : "true"
					}
				}
			},
			/* "sharedView" : sharedView, */
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "submit",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}
					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					PostData.author=new Array();
					PostData.author[0]=new Object();
					PostData.author[0].email=new Object();
					PostData.author[0].email=User.Email;

					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();
				
				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// Measurement Capability

var meas_capab = {
	"metro" : {
		"title" : "Measurement Capability",
		"location" : "AjaxField.html",
		"description" : "Measurement Capability",
		"hide" : "false"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/meas_capab/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "Measurement Capability:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"OpenNewDialog" : {
						"type" : "button",
						"style" : "open-dialog-button",
						"labelStyle" : "label",
						"label" : "measure property:",
						"value" : "open",
						"click" : function() {
							$("#meas_prop_menu", window.parent.document).trigger("click");

						}
					},
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : " Measurement Capability id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"measurement_properties" : {
						"label" : "Measurement Property URIs:",
						"type" : "uri",
						"labelStyle" : "label",
						"level" : "2",
						"isData" : "true"
					},
					"observed_property" : {
						"label" : "Property this capability:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "MeasurementCapability",
						"isData" : "true"
					}
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// Measurement Property
var meas_prop = {
	"metro" : {
		"title" : "Measurement Property",
		"location" : "AjaxField.html",
		"description" : "Measurement Property",
		"hide" : "true"
	},
	"page" : {// here is the information for the page
		"ajax" : {
			"url" : "/meas_prop/",
			"type" : "post",
			"dataType" : "html",
			"contentType" : "application/json; charset=utf-8"
		},
		"view" : {
			"SensorLabel" : {
				"type" : "label",
				"message" : "Measurement Property:",
				"style" : "label-message"
			},
			"Basic" : {
				"type" : "div",
				"style" : "Field-content",
				"content" : {
					"storeDiv" : storeDiv,
					"resourceId" : {
						"label" : " Measurement Property id:",
						"type" : "input",
						"labelStyle" : "label-red",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"uom" : {
						"label" : "unit of measurement:",
						"type" : "input",
						"labelStyle" : "label",
						"level" : "0",
						"defaultValue" : "Centigrade",
						"isData" : "true"
					},
					"predicate" : {
						"label" : "predicate:",
						"type" : "uri",
						"level" : "0",
						"isData" : "true"
					},
					/*
					 * "value" : { "label" : "value:", "type" : "input", "level" :
					 * "0", "defaultValue" : "", "isData" : "true" },
					 */
					"MinValue" : {
						"label" : "MinValue:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"MaxValue" : {
						"label" : "MaxValue:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "",
						"isData" : "true"
					},
					"type" : {
						"label" : "type:",
						"type" : "input",
						"level" : "0",
						"defaultValue" : "MeasurementProperty",
						"isData" : "true"
					},
					"conditions" : {
						"label" : "conditions:",
						"type" : "muti-input",
						"level" : "2",
						"children" : {
							"oncondition_uom" : {
								"label" : "unit of measurement:",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							},
							/*
							 * "oncondition_value" : { "label" : " condition
							 * value:", "type" : "input", "level" : "3",
							 * "isData" : "true" },
							 */
							"oncondition_predicate" : {
								"label" : "condition predicate:",
								"type" : "input",
								"level" : "3",
								"isData" : "true"
							},
							"oncondition_property" : {
								"label" : "condition property:",
								"type" : "uri",
								"level" : "3",
								"isData" : "true"
							}
						},
						"isData" : "true"
					},
				}
			},
			"sharedView" : sharedView,
			"generateButton" : {
				"type" : "button",
				"style" : "generateButton",
				"label" : "",
				"value" : "generate",
				"click" : function() {
					// get common data

					var data = GetCommonData();
					// get url info

					var commonData = GetAjaxData();
					//

					var key = request("key");
					var view = AppData[key].page.view;
					var ajaxOpt = $.extend({}, AppData[key].page.ajax);

					var PostData = $.extend(data.sendData, commonData);
					if (data.AjaxData.uri == undefined) {
						PostData.uri = ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;

					} else {
						ajaxOpt.url = serverLocation + AppData[key].page.ajax.url + PostData.resourceId;
						var s = data.AjaxData.uri.charAt(data.AjaxData.uri.length - 1);
						if (s != '/') {
							data.AjaxData.uri = data.AjaxData.uri + '/';
						}
						PostData.uri = data.AjaxData.uri + data.sendData.resourceId;// use

					}

					if (data.AjaxData.serializeType != undefined) {
						ajaxOpt.Accept = data.AjaxData.serializeType;
					}
					var ajaxprocess = new AjaxProcess(ajaxOpt, PostData);
					ajaxprocess.doAjax();

				}
			},
			"result" : {
				"type" : "div",
				"style" : "code-result",
				"content" : {

				}
			}
		}
	}
};

// main json data
var AppData = window.AppData = {
	"ov" : ov,// Observation Value
	"device" : device,// Device, Sensing Device, Sensor
	"tps" : tps,// Sensor Temporal Property
	"platform" : platform,// Platform, Testbed
	"tpp" : tpp,// Platform Temporal Property
	"meas_capab" : meas_capab,// Measurement Capability
	"meas_prop" : meas_prop, // Measurement Property
	"data_link" : data_link,//
	"link_review" : link_review,// Link Review
	"Aggregate" : {
		"metro" : {
			"title" : "Aggregate",
			"location" : "Aggregate.html",// special page so null
			"description" : "Aggregate page"
		},
		"page" : {}
	},
	"viewResult" : {
		"metro" : {
			"title" : "Browse",
			"location" : "viewResult.html",
			"description" : "to view the result"
		},
		"page" : {}
	},
	"search" : {
		"metro" : {
			"title" : "search",
			"location" : "Search.html",
			"description" : "Search page"
		},
		"page" : {}
	},
	"sdFactory" : {
		"metro" : {
			"title" : "sd factory",
			"location" : "sdFactory.html",
			"description" : "create sd"
		},
		"page" : {}
	},
	"AjaxAPI" : {
		"metro" : {
			"title" : "AjaxAPI",
			"location" : "jqueryAjax.html",// special page so null
			"description" : "Ajax API for common function",
			"hide" : "true"
		},
		"page" : {}
	}
};

// ajax common function
function AjaxProcess(opt, data) {

	var _default = {
		"url" : "http://localhost:8182/ld4s/ov",
		"type" : "post",
		"dataType" : "json",
		"crossDomain" : "true",
		"contentType" : "application/json; charset=utf-8",
		"Accept" : "application/rdf+json"
	};// default value

	var $t = this;
	$t.o = $.extend(_default, opt);
	$t.data = data;

	// common function for success
	var AjaxSuccess = function(returnData) {
		window.clock = false;
		// convert to link
		function AddLink(text) {
			if (text.indexOf("http") == -1) {
				return text;
			} else {
				var start = text.indexOf("http");
				var end = text.indexOf("&quot;", start);
				var end2 = text.indexOf("&gt;", start);
				end = end < end2 ? end2 : end;
				var link = text.substring(start, end);
				var linkString = "<a href='" + link + "'  target='_blank'>" + link + "</a>";
				return text.replace(link, linkString);
			}
		}

		function removeLink(text) {
			if (text.indexOf("<a") == -1) {
				return text;
			} else {
				var start = text.indexOf("<a");
				var end = text.indexOf("a>") + 2;
				var linkString = text.substring(start, end);
				var linkstart = linkString.indexOf(">") + 1;
				var linkend = linkString.indexOf("</a>");
				var link = linkString.substring(linkstart, linkend);
				return text.replace(linkString, link);
			}
		}

		$("#result").html("");
		var toolBar = "<div class='toolbar'><div class='toolbar-button-div'><a class='ui-icon-disk' id='save'>save</a></div>" + "<div class='toolbar-button-div'><a class='ui-icon-pencil'id='edit'>edit</a></div>"
				+ "<div class='toolbar-button-div'><a class='ui-icon-arrowreturnthick-1-n' id='update'>update</a></div>" + "<div class='toolbar-button-div'><a class='ui-icon-document' id='openNewWindow'>see result in new window</a></div>" + "</div>";

		$("#result").append(toolBar);
		$("#save").button({
			text : true,
			icons : {
				primary : "ui-icon-disk"
			}
		}).click(function() {
			window.payloadCodeArea.save();
		});

		$("#edit").button({
			text : true,
			icons : {
				primary : "ui-icon-pencil"
			}
		}).click(function() {
			window.payloadCodeArea.edit();
		});

		$("#update").button({
			text : true,
			icons : {
				primary : "ui-icon-arrowreturnthick-1-n"
			}
		}).click(function() {
			// function for sending post function
			var sendData = window.payloadCodeArea.data;

			$.ajax({
				type : "post",
				data : sendData,
				contentType : window.$t.o.Accept,
				url : window.$t.sendingURI,
				dataType : "html",
				error : function() {
					$("#updateMessage").remove();
					$("#result").prepend("<div id='updateMessage' class='red-color '>error,the data can not be accepted.please generate it again or edit the file.</div>");
				},
				headers : {
					"Accept" : window.$t.o.Accept
				},
				success : function() {
					$("#updateMessage").remove();
					$("#result").prepend("<div id='updateMessage' class='red-color'>success,the generate data has been saved in the remote!</div>");
				}
			});

		});

		$("#openNewWindow").button({
			text : true,
			icons : {
				primary : "ui-icon-document"
			}
		}).click(function() {

			if ($("#viewResult_menu_tab", window.parent.document).length == 0) {

				var viewResult = new Object();
				viewResult.uri = window.$t.sendingURI;
				viewResult.datatype = window.$t.o.Accept;
				$.cookie("viewResult", JSON.stringify(viewResult), {
					path : '/',
					expires : 1
				});// expires date change here
				$("#viewResult_menu", window.parent.document).trigger("click");
			} else {
				// var doc =
				// window.parent.window.frames["viewResultIframe"].document;
				$("#viewResult_menu", window.parent.document).trigger("click");
				// $("#uri", doc).val(window.$t.sendingURI);
			}

		});

		var showingDiv = "<div class='codeArea-div'></div>";
		$("#result").append(showingDiv);
		// create code area

		$.ajax({
			type : "get",
			contentType : $t.o["contentType"],
			url : window.$t.sendingURI,
			async : true,
			dataType : "html",
			error : function() {
				window.clock = false;
			},
			headers : {
				"Accept" : $t.o.Accept
			},
			success : function(data) {
				$(".codeArea-div").html("");
				window.payloadCodeArea = $(".codeArea-div").codeArea(data);
				// see also code

				var index = returnData.indexOf("seeAlsoLink", 0);
				if (index != -1) {
					// create datalink

					function createDataLinkHtml() {
						$("#result").append("<div id='dataLink'></div>");
						// get data
						var dataLink = $.parseJSON(returnData);
						var seeAlso;
						$.each(dataLink[window.$t.sendingURI], function(key) {
							if (key.indexOf("seeAlsoLink") != -1) {
								seeAlso = this;
							}
						});

						seeAlsoData = new Object();
						$.each(seeAlso, function(k) {
							seeAlsoData[this.value] = dataLink[this.value];
						});

						/*
						 * here is test code!!!!!!!!!!!!!!!!!!!!!!!!!for see
						 * also please delete when using!
						 */
						/*
						 * $.ajax({ dataType : "json", async : false, url :
						 * '../seealsolinkdata.json', success : function(data) {
						 * seeAlsoData = data; } });
						 */
						/**
						 * end of insert code!!!
						 */

						//
						// delete dataLink[$t.o["url"]];
						var dataLinkCount = 0;
						var Html = "";
						var testWords = [ "title", "temporal", "from", "to", "updated", "feedbacks" ];
						function createDataLink(testWord, data, k) {

							if (k.indexOf("/" + testWord, 0) != -1) {
								Html += "    " + testWord + " : ";
								$.each(data, function() {
									Html += this.value + "   ";
								});// end of each
								Html += "\n";
							}
						}
						// should not send dataLink
						$.each(seeAlsoData, function(key) {
							dataLinkCount = dataLinkCount + 1;
							$("#dataLink").append("<div id='dataLink" + dataLinkCount + "'></div>");
							$("#dataLink" + dataLinkCount).append("<h3>In " + key + ":</h3>");
							$("#dataLink" + dataLinkCount).append("<div class='codePart'></div>");

							var urlKey = key.replace("http://", "");

							var code = "<br/><iframe src=\"AjaxField.html?key=link_review&Url=" + urlKey + "\" " + "style=\"width:100%;height:500px;border:0px\" class=\"LinkReviewIframe\" ></iframe>";

							$("#dataLink" + dataLinkCount).append(code);

							$.each(seeAlsoData[key], function(k) {
								$t = this;
								$.each(testWords, function() {
									createDataLink(this, $t, k);
								});
							});// end of each
							$("#dataLink" + dataLinkCount).find(".codePart").codeArea(Html);
							Html = "";// clean the data for loop
							$("#dataLink" + dataLinkCount).append("<br/>");
							// here should be the code generate commit

							$("#dataLink" + dataLinkCount).append("<div  class='dataLinkForms" + dataLinkCount + "'> </div>");

							$t = this;
							$.each($t, function(k) {
								if (k.indexOf("/feedbacks", 0) != -1) {
									var counter = 1000;
									$.each(this, function() {

										$(".dataLinkForms" + dataLinkCount).append("<h3>" + this.value + "</h3>");
										html = "<div class='Field-content dataLinkForm" + (dataLinkCount + counter) + "'>" + "<table><tr><td><span class=\"label\">surname:</span></td><td><input type='text' surname /></td></tr></table>"
												+ "<table><tr><td><span class=\"label\">firstname:</span></td><td><input type='text' firstname /></td></tr></table>" + "<table><tr><td><span class=\"label\">rate:</span></td><td><div class='star'></div></td></tr></table>"
												+ "<span class=\"label\">comment:</span><br/>" + "<textarea style='margin-left:150px;width:500px;height:100px'></textarea><br/>" + "<input type='button' value='submit' style='margin-left:200px'/>" + "<input type='hidden' class='score"
												+ (dataLinkCount + counter) + "' value='3'/>" + "</div>";
										$(".dataLinkForms" + dataLinkCount).append(html);
										var tempstr = '.score' + (dataLinkCount + counter);
										$(".dataLinkForm" + (dataLinkCount + counter)).find(".star").raty({
											starHalf : '../Images/star-half.png',
											starOn : '../Images/star-on.png',
											starOff : '../Images/star-off.png',
											click : function(score) {
												$(tempstr).val(score);
											},
											score : 3
										});
										$(".dataLinkForm" + (dataLinkCount + counter)).find("input[type=button]").button().unbind("click").click(function() {
											var sendData = new Object();
											sendData.link = new Array();
											sendData.link.push(key);
											sendData.author = new Array();
											sendData.author[0] = new Object();
											sendData.author[0]["surname"] = $(this).parent().find('input[surname]').val();
											sendData.author[0]["firstname"] = $(this).parent().find('input[firstname]').val();
											sendData.vote = new Array();
											sendData.vote[0] = $(this).parent().find('input[type=hidden]').val();
											sendData.comment = new Array();
											sendData.comment[0] = $(this).parent().find("textarea").val();

											$.ajax({
												data : JSON.stringify(sendData),
												url : this.value,
												type : "put",
											});
											console.log("send data: " + JSON.stringify(sendData) + "to " + this.value);
										});

										counter += 1000;
									});
								}
							});

							//
							$("#dataLink" + dataLinkCount).append("<br/>");
							$("#dataLink" + dataLinkCount).append("<br/>");
						});
					}

					createDataLinkHtml();
				} else {
					// do not have see also
				}

				// add code for showing linkreview
				
				if (request("key") == "link_review") {
					// $("#result").hide();
					$(".toolbar").hide();
					$("#reviewsuccess").remove();
					$("body").append("<div id='reviewsuccess'>add review success!</div>");
					debugger
					$(".LinkReviewIframe", window.parent.document).css("height", $(document.body).height()+40);
				}
			}
		});

		// add share
		function share() {
			var share = "<div class='addthis_toolbox addthis_default_style '>" + "<a class='addthis_button_facebook_like' fb:like:layout='button_count'></a>" + "<a class='addthis_button_tweet'></a>" + "</div>";
			$("#result").append(share);
			var script = "<script type=\"text/javascript\">var addthis_config = {\"data_track_addressbar\":true};</script>" + "<script type=\"text/javascript\" src=\"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-51dd7d9e5f19e217\"></script>";
			$("body").append(script);
		}
		share();

		// show note
		$("#result").prepend("<div>note:<br/><strong>" + window.$t.sendingURI + "</strong> is the resource uri <br/></div>");

	};

	this.doAjax = function() {
		$t.sendingURI;

		if ($t.data.SendingURI == undefined) {
			$t.sendingURI = $t.o["url"];
		} else {
			$t.sendingURI = $t.data.SendingURI;
			// $t.data.uri = $t.data.SendingURI;
			delete $t.data.SendingURI;
		}

		window.$t = $t;
		console.log(JSON.stringify($t.data));
		console.log("send to " + $t.sendingURI);
		$.ajax({
			type : $t.o["type"],
			data : JSON.stringify($t.data),
			contentType : $t.o["contentType"],
			url : window.$t.sendingURI,
			dataType : "html",
			async : true,
			error : function() {
				window.clock = false;
			},
			headers : {
				"Accept" : "application/rdf+json"
			},
			success : AjaxSuccess,
			beforeSend : function(e, xhr, o) {
				window.clock = true;
				window.clockCount = 1;
				var showMessage = "server is processing";
				window.changeMessage = function() {
					if (window.clock) {
						if (window.clockCount < 10) {
							showMessage += ".";
							$("#result").html(showMessage);
							window.clockCount++;
							setTimeout("changeMessage()", 1000);
						} else {
							$("#result").html("server may be busy, please try it later");
						}

					}

				}
				changeMessage();

			},
			statusCode : {
				404 : function() {
					alert("404:Sorry, Not Found Data");
				},
				415 : function() {
					alert("415:Sorry, media type error,Please refresh page and change you data formate");
				},
				500 : function() {
					alert(" 500:Sorry, server side error, Please refresh page and send email to administrator.");
				},
				405 : function() {
					alert("405,Sorry ,server side method error, Please try to use Post function send data");
				}
			}
		});

	};
}

function GetCommonData() {
	var returnData = new Object();

	returnData.sendData = new Object();
	returnData.AjaxData = new Object();
	// this function divided to 4 part

	// get Context data
	if ($("#contextbutton").attr("checked") == "checked" || $("#contextbutton").attr("checked") == "true") {

		var contextString = "";

		if ($("#context").find("input[checked]").length > 0) {
			contextString += "d=";

			$("#context").find("input[checked=checked]").each(function(key) {
				if (key == 0) {
					contextString += $(this).attr("id");
				} else {
					contextString += "%20OR%20" + $(this).attr("id");
				}
			});
		}

		// get tree data function
		function getTREEDATA(key) {
			var ztree = $.fn.zTree.getZTreeObj(key);
			var treedata = ztree.getNodes();
			var returnString = "";

			if (treedata[0].children == undefined) {
				return "";
			} else {
				var temp = "";

				function Childrendata(obj) {
					$.each(obj, function(k) {
						if (this.children == undefined) {
							temp += this.name;
						} else {
							temp += this.name;
							temp += "(";
							Childrendata(this.children);
							temp += ")";
						}

						if (k != obj.length - 1) {
							temp += ",";
						}
					});
				}

				Childrendata(treedata[0].children);

				if (temp.length != 0) {
					return "OR(" + temp + ")";
				}

			}

		}

		var s = "";
		if (getTREEDATA("NEAR") != "" && getTREEDATA("NEAR") != undefined) {
			s += "NEAR(" + getTREEDATA("NEAR") + ")";
		}

		if (getTREEDATA("UNDER") != "") {
			s += "UNDER(" + getTREEDATA("UNDER") + ")";
		}
		if (getTREEDATA("OVER") != "") {
			s += "OVER(" + getTREEDATA("OVER") + ")";
		}
		if (getTREEDATA("IN") != "") {
			s += "IN" + getTREEDATA("IN") + ")";
		}
		if (getTREEDATA("OF") != "") {
			s += "OF" + getTREEDATA("OF") + ")";
		}

		if (s != "") {
			if (contextString == "") {
				contextString = "s=" + s;
			} else {
				contextString += "&" + "s=" + s;
			}
		}

		// get things data

		var th = getTREEDATA("Things");

		if (th != "") {
			if (contextString == "") {
				contextString = "th=" + th;
			} else {
				contextString += "&" + "th=" + th;
			}
		}

		// add start and end

		var start = $("#context").find("#start_datetime").val();
		var end = $("#context").find("#end_datetime").val();
		if (start.length != 0 && end.length != 0) {
			if (contextString == "") {
				contextString = "trange=" + start + "_" + end;
			} else {
				contextString += "&" + "trange=" + start + "_" + end;
			}

		}

		returnData.sendData["context"] = contextString;
	}

	// get optional data
	if ($("#commonChoiceLabel").attr("checked") == "checked" || $("#commonChoiceLabel").attr("checked") == "true") {
		$("#commonChoiceDiv").find(".AjaxData").each(function(key) {
			if ($(this).attr("level") != "2" && $(this).val().length != 0) {
				if ($(this).attr("uri") == "true") {
					returnData.sendData[$(this).attr("id")] = "http://" + $(this).val();
				} else {
					returnData.sendData[$(this).attr("id")] = $(this).val();
				}

			}
		});
	}

	// get author data

	if ($("#AuthorLabel").attr("checked") == "checked" || $("#AuthorLabel").attr("checked") == "true") {
		returnData.sendData["author"] = new Array();
		returnData.sendData["author"][0] = new Object();
		$("#AuthorDiv").find(".AjaxData").each(function() {
			if ($(this).attr("level") != "2" && $(this).val().length != 0) {
				if ($(this).attr("uri") == "true") {
					returnData.sendData.author[0][$(this).attr("id")] = "http://" + $(this).val();
				} else {
					returnData.sendData.author[0][$(this).attr("id")] = $(this).val();
				}

			}
		});
	}
	// get store data

	/*
	 * if ($("#storeDataLabel").attr("checked") == "checked" ||
	 * $("#storeDataLabel").attr("checked") == "true") { if
	 * ($("#storeType").attr("checked") == "checked" ||
	 * $("#storeType").attr("checked") == "true") { if ($("#uri").val() != "") {
	 * returnData.AjaxData["uri"] = "http://" + $("#uri").val(); } }
	 * 
	 * if ($("#serializeType").attr("value").length != 0) {
	 * returnData.AjaxData["serializeType"] = $("#serializeType").attr("value"); } }
	 */

	if ($("#uri").val() != "" && $("#storeType").attr("value") == "myDB") {
		returnData.AjaxData["uri"] = "http://" + $("#uri").val();
	}

	if ($("#serializeType").attr("value") != undefined && $("#serializeType").attr("value").length != 0) {
		returnData.AjaxData["serializeType"] = $("#serializeType").attr("value");
	}

	return returnData;

}

// common function for get ajaxData
function GetAjaxData() {
	var AjaxData = new Object();

	$(".Field-content").find(".AjaxData").each(function() {
		if ($(this).val() != "" && $(this).val() != null && $(this).val() != undefined && $(this).attr("level") != 3) {
			var key = $(this).attr("id");
			if ($(this).attr("uri") == "true") {
				AjaxData[$(this).attr("id")] = "http://" + $(this).val();
			} else {
				AjaxData[$(this).attr("id")] = $(this).val();

			}

		}
	});

	$(".Field-content").find(".AjaxData").each(function() {
		var key = $(this).attr("id");
		if ($(this).attr("level") != undefined && ($(this).attr("level") == 1 || $(this).attr("level") == 2)) {
			var level = $(this).attr("level");
			AjaxData[key] = new Array();
			if (level == "1") {
				$(this).find("input").each(function() {
					if ($(this).val() != "" && $(this).val() != null) {

						if ($(this).attr("uri") == "true") {
							AjaxData[key].push("http://" + $(this).val());
						} else {
							AjaxData[key].push($(this).val());
						}

					}
				});
			} else if (level == "2") {
				AjaxData[key][0] = new Array();
				$(this).find("input[class!=http]").each(function() {
					if ($(this).val() != "" && $(this).val() != null) {
						if ($(this).attr("uri") == "true") {
							AjaxData[key][0].push("http://" + $(this).val());
						} else {
							AjaxData[key][0].push($(this).val());
						}

					}
				});

			}
		}
	});

	// get level 3 data

	$(".Field-content").find(".muti-input").each(function() {
		var key = $(this).attr("id");
		AjaxData[key] = new Array();
		AjaxData[key][0] = new Array();
		$(this).find(".muti-item").each(function() {
			var o = new Object();
			$(this).find("input[level=3]").each(function() {
				if ($(this).attr("uri") == "true") {
					o[$(this).attr("name")] = "http://" + $(this).val();
				} else {
					o[$(this).attr("name")] = $(this).val();
				}

			});
			AjaxData[key][0].push(o);
		});
	});

	return AjaxData;

}

/**
 * core function use the data to create the html
 * 
 */
function createHTML(view, jqueryParent) {
	$.each(view, function(key) {
		switch (this.type) {
		case "div":
			//
			var _default = {
				"type" : "div",
				"style" : "",// could set default style
				"content" : undefined
			};

			var $v = $.extend(_default, this);

			var string = "<div id='" + key + "'></div>";
			jqueryParent.append(string);
			var $t = $("#" + key);
			$t.addClass($v.style);
			if (this.content != undefined) {
				createHTML($v.content, $t);
			}
			break;
		case "input":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"style" : "",
				"type" : "input",
				"level" : "0",
				"defaultValue" : "",
				"isData" : "false"
			};
			var $v = $.extend(_default, this);

			var $t;

			if ($v.level == 0) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input id='" + key + "' type='text' value='" + $v.defaultValue + "' ";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData'";
				}
				string += "/></td></tr>" + "</table></div>";

				jqueryParent.append(string);

			} else if ($v.level == 1 || $v.level == 2) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table id='" + key + "' level='" + $v.level + "'";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData'";
				}

				string += "><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input class='" + key + "' type='text' value='" + $v.defaultValue + "'  />" + "</td><td><a  id='" + key + "_link'>Add value</a></td></tr>" + "</table></div>";
				jqueryParent.append(string);

				$("#" + key + "_link").button().click(function() {
					var tr = "<tr  class=''><td><span class='" + $v.labelStyle + "'>" + $v.label + "</span></td><td><input class='" + key + "' type='text' /></td><td><a  class='removeLink'>remove</a></td></tr>";
					$("#" + key + "").append(tr);

					$(".removeLink").button().click(function() {
						$(this).parent().parent().remove();
					});
					initialInput();
				});
			} else if ($v.level == 3) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input name='" + key + "' type='text' level='3' value='" + $v.defaultValue + "' ";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData'";
				}
				string += "/></td></tr>" + "</table></div>";

				jqueryParent.append(string);
			}

			break;

		case "button":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"type" : "button",
				"value" : "",
				"labelStyle" : "",
				"style" : "",
				"isData" : "false",
				"click" : function() {
				}
			};
			var $v = $.extend(_default, this);

			var html = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td><div class='" + $v.labelStyle + "'>" + $v.label + "</div></td><td><input type='button' id='" + key + "' value='" + $v.value + "' class='ui-button-text'/></td></tr></table></div>";
			jqueryParent.append(html);
			$("#" + key).button().click($v.click);
			break;
		case "label":
			var html = "<div id='" + key + "'>" + this.message + "</div>";
			jqueryParent.append(html);
			$("#" + key).addClass(this.style);
			break;
		case "radio":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"style" : "",
				"type" : "radio",
				"isData" : "false",
				"click" : function() {
				}
			};
			var $v = $.extend(_default, this);
			var html = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td><div>" + $v.label + "</div></td><td><div id='" + key + "' value ></div></td></tr></table></div>";
			jqueryParent.append(html);
			var $self = this;
			var $t = $("#" + key);
			$.each(this.children, function(key) {

				var html = "<input type='radio' id='" + key + "' name='" + $t.attr("id") + "' value='" + this.value + "'  /><label for='" + key + "'>" + this.label + "</label>";
				$t.append(html);

				$("#" + key).click(function() {
					if ($self.children[key].click != undefined) {
						$self.children[key].click();
					}
				});
			});
			$t.buttonset();

			$("input[name='" + $t.attr("id") + "']").click(function() {
				$t.attr("value", $(this).attr("value"));
				$v.click();
			});

			// set default value
			$.each(this.children, function(key) {
				if (this.checked == "true") {
					$("label[for=" + key + "]").trigger("click");
				}
			});

			break;
		case "datetime":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"type" : "datetime",
				"style" : "",
				"defaultValue" : "",
				"isData" : "false"
			};
			var $v = $.extend(_default, this);

			var $t;
			var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input id='" + key + "' type='text' value='" + $v.defaultValue + "' ";
			if ($v.isData == "true" || $v.isData == true) {
				string += "class='AjaxData'";
			}
			string += "/></td></tr>" + "</table></div>";

			jqueryParent.append(string);

			$('#' + key).datetimepicker({
				"dateFormat" : "dd-mm-y",
				timeFormat : 'HH:mm:ss z',
				'separator' : "T"
			});
			break;
		case "date":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"type" : "date",
				"style" : "",
				"defaultValue" : "",
				"isData" : "false"
			};
			var $v = $.extend(_default, this);

			var $t;
			var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input id='" + key + "' type='text' value='" + $v.defaultValue + "' ";
			if ($v.isData == "true" || $v.isData == true) {
				string += "class='AjaxData'";
			}
			string += "/></td></tr>" + "</table></div>";

			jqueryParent.append(string);

			$('#' + key).datepicker({

				"dateFormat" : "dd.mm.yy"
			});
			break;
		case "checkbox":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"type" : "checkbox",
				"value" : "",
				"style" : "",
				"checked" : "false",// "checked"||"false"
				"isData" : "false",
				"click" : function() {
				}
			};
			var $v = $.extend(_default, this);

			var html = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td><div class='" + $v.labelStyle + "'>" + $v.label + "</div></td><td><input type='checkbox' id='" + key + "'  ";
			if ($v.checked == "true" || $v.checked == "checked") {
				html += " checked='true' ";
			}
			if ($v.isData == "true" || $v.isData == true) {
				html += "class='AjaxData'";
			}
			html += "/><label for='" + key + "'>" + $v.value + "</label></td></tr></table></div>";
			jqueryParent.append(html);

			$("#" + key).button().click(function() {
				if ($("#" + key).attr("checked") != true && $("#" + key).attr("checked") != "checked") {

					$("#" + key).attr("checked", true);
				} else {
					$("#" + key).attr("checked", false);
				}

				$v.click();
			});
			break;
		case "map":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"style" : "",
				"type" : "input",
				"level" : "0",
				"defaultValue" : "",
				"isData" : "false",
				"click" : function() {
				}
			};
			var $v = $.extend(_default, this);

			var html = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td style='text-align: left;width:30px;'>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td style='text-align: left;'>" + "<input id='" + key + "' type='text' value='"
					+ $v.defaultValue + "' ";
			if ($v.isData == "true" || $v.isData == true) {
				html += "class='AjaxData'";
			}
			html += "/></td></tr>" + "<tr><td colspan='2'>" + "<div id='" + key + "_map' class='map-div'></div></td></tr>" + "</table></div>";

			jqueryParent.append(html);
			var latlng = new google.maps.LatLng(31.311160897431638, 121.53830409049988);// initial
			// location
			var myOptions = {
				zoom : 1,// level of map,how big it is
				center : latlng,// location
				mapTypeId : google.maps.MapTypeId.ROADMAP
			// mode of map
			};

			var thisMap = new google.maps.Map($("#" + key + "_map")[0], myOptions);
			map.push(thisMap);
			window.marker = null;
			var geocoder = new google.maps.Geocoder();
			var infowindow = new google.maps.InfoWindow();
			google.maps.event.addListener(thisMap, 'click', function(event) {
				var text = event.latLng.lat() + "_" + event.latLng.lng();
				$("#" + key).val(text);
				geocoder.geocode({
					'latLng' : event.latLng
				}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
						if (results[1]) {
							if (window.marker == null) {
								marker = new google.maps.Marker({
									position : event.latLng,
									map : thisMap
								});
							} else {
								marker.setPosition(event.latLng);
							}
							Address = results[1].formatted_address;
							$v.click(results);

							infowindow.setContent(results[1].formatted_address);
							infowindow.open(thisMap, marker);

						}
					}
				});

			});

			break;

		case "tree":

			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"style" : "",
				"type" : "input",
				"defaultValue" : "",
				"isData" : "false",
				"click" : function() {
				}
			};

			var $v = $.extend(_default, this);

			var setting = {
				view : {
					selectedMulti : false
				},
				edit : {
					enable : true,
					showRemoveBtn : false,
					showRenameBtn : false
				},
				data : {
					keep : {
						parent : true,
						leaf : true
					},
					simpleData : {
						enable : true
					}
				}
			};

			var zNodes = [ {
				id : 1,
				pId : 0,
				name : $v.label,
				isParent : true,
				open : true
			},

			];

			var html = "<div id='" + key + "OutDiv' class='" + $v.style + "'><div id='" + key + "' class='ztree'></div>" + "</div>";
			jqueryParent.append(html);

			var thisTree = $.fn.zTree.init($("#" + key), setting, zNodes);

			var buttonSet = "<div id='" + key + "buttonSet'>" + "<input type='button' id='" + key + "AndButton' value='add AND relation'> " + "<input type='button' id='" + key + "orButton' value='add OR relation'> " + "<input type='button' id='" + key + "PlaceButton' value='Add Parameter'> "
					+ "<input type='button' id='" + key + "Delete' value='delete'>" + "<input type='button' id='" + key + "Edit' value='Edit'>" + "</div>";

			$("#" + key + "OutDiv").append(buttonSet);

			$("#" + key + "buttonSet").buttonset();

			var zTree, treeNode;
			function add(name, isparent) {
				zTree = $.fn.zTree.getZTreeObj(key), nodes = zTree.getSelectedNodes();
				treeNode = nodes[0];
				if (treeNode) {
					treeNode = zTree.addNodes(treeNode, {
						id : TreeCount,
						pId : treeNode.id,
						isParent : isparent,
						name : name
					});
				} else {
					alert("please select a node");
				}

				TreeCount++;
			}

			$("#" + key + "AndButton").click(function() {

				add("AND", true);

			});

			$("#" + key + "orButton").click(function() {
				add("OR", true);

			});
			$("#" + key + "PlaceButton").click(function() {
				add("", false);
				zTree.editName(treeNode[0]);
			});
			$("#" + key + "Delete").click(function() {
				var zTree = $.fn.zTree.getZTreeObj(key), nodes = zTree.getSelectedNodes(), treeNode = nodes[0];
				if (nodes.length == 0) {
					alert("please select a node");
					return;
				}

				if (treeNode.id == 1) {
					alert("can not delete root");
				} else {
					zTree.removeNode(treeNode);
				}

			});

			$("#" + key + "Edit").click(function() {
				var zTree = $.fn.zTree.getZTreeObj(key), nodes = zTree.getSelectedNodes(), treeNode = nodes[0];
				if (nodes.length == 0) {
					alert("please select a node");
					return;
				}

				if (treeNode.id == 1) {
					alert("can not edit root");
				} else {
					zTree.editName(treeNode);
				}
			});

			break;
		case "muti-input":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"type" : "muti-input",
				"value" : "add more",
				"style" : "",
				"isData" : "false",
				"children" : {},
				"click" : function() {
				}
			};
			var $v = $.extend(_default, this);

			var html = "<div id='" + key + "' class='" + $v.style + " muti-input'><table><tr><td><div class='" + $v.labelStyle + "'>" + $v.label + "</div></td><td><input type='button'  id='" + key + "button' value='" + $v.value + "'/></td></tr></table></div>";
			jqueryParent.append(html);
			$("#" + key + "button").button().click(function() {
				var DivID = key + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds() + new Date().getSeconds() + new Date().getMilliseconds();
				$("#" + key).append("<div id='" + DivID + "' class='muti-item'></div>");
				createHTML($v.children, $("#" + DivID));
				$("#" + DivID).append("<div style='text-align:center'><a id='" + DivID + "link'>remove</a></div>");
				initialInput();
				$("#" + DivID + "link").button().click(function() {
					$("#" + DivID).remove();
				});

			});

			// create first level
			var DivID = key + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds() + new Date().getSeconds() + new Date().getMilliseconds();
			$("#" + key).append("<div id='" + DivID + "' class='muti-item'></div>");
			createHTML($v.children, $("#" + DivID));

			break;
		case "uri":
			var _default = {
				"label" : "",
				"labelStyle" : "label",
				"style" : "",
				"type" : "url",
				"level" : "0",
				"defaultValue" : "",
				"title" : "http://",
				"isData" : "true"
			};
			var $v = $.extend(_default, this);

			var $t;

			if ($v.level == 0) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input type='text' value='" + $v.title + "' disabled class='http' /><input id='" + key + "' type='text' value='"
						+ $v.defaultValue + "'  uri='true'";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData uri'";
				}
				string += "/></td></tr>" + "</table></div>";

				jqueryParent.append(string);

			} else if ($v.level == 1 || $v.level == 2) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table id='" + key + "' level='" + $v.level + "'";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData'";
				}

				string += "><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input type='text' value='" + $v.title + "' disabled class='http' /><input class='" + key + " uri' type='text' value='" + $v.defaultValue + "' uri='true' />"
						+ "</td><td><a  id='" + key + "_link'>Add value</a></td></tr>" + "</table></div>";
				jqueryParent.append(string);

				$("#" + key + "_link").button().click(
						function() {
							var tr = "<tr  class=''><td><span class='" + $v.labelStyle + "'>" + $v.label + "</span></td><td><input type='text' value='" + $v.title + "' disabled class='http' /><input class='" + key + " uri ' type='text' value='" + $v.defaultValue
									+ "' uri='true' /></td><td><a  class='removeLink'>remove</a></td></tr>";
							$("#" + key + "").append(tr);

							$(".removeLink").button().click(function() {
								$(this).parent().parent().remove();
							});
							initialInput();
						});
			} else if ($v.level == 3) {
				var string = "<div id='" + key + "OutDiv' class='" + $v.style + "'><table><tr><td>" + "<span class='" + $v.labelStyle + "'>" + $v.label + "</span>" + "</td>" + "<td>" + "<input type='text' value='" + $v.title + "' disabled class='http' /><input name='" + key
						+ "' type='text' level='3' value='" + $v.defaultValue + "' uri='true'";
				if ($v.isData == "true" || $v.isData == true) {
					string += "class='AjaxData uri' ";
				}
				string += "/></td></tr>" + "</table></div>";

				jqueryParent.append(string);
			}

			break;

		}
	});

	$(".Field-content-hide").hide();

}